From 573a3b1dafe46fa2c268af2d5c31a29cd3e044ff Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 11 Apr 2010 18:11:46 +0000 Subject: [PATCH] Allow notification of betas to be independent of notifications of real upgrades. --- gui/babeldata.h | 7 +++++-- gui/mainwindow.cpp | 23 ++++++++++++++++++----- gui/mainwindow.h | 5 ++++- gui/upgrade.cpp | 8 +++++--- gui/upgrade.h | 3 ++- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/gui/babeldata.h b/gui/babeldata.h index 5f87fb5a4..2bf8c6eb8 100644 --- a/gui/babeldata.h +++ b/gui/babeldata.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: babeldata.h,v 1.5 2010/02/15 02:57:00 robertl Exp $ +// $Id: babeldata.h,v 1.6 2010/04/11 18:11:46 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -58,7 +58,8 @@ public: upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))), installationUuid(QUuid::createUuid().toString()), startupVersionCheck(true), - reportStatistics(true) + reportStatistics(true), + allowBetaUpgrades(false) { }; @@ -105,6 +106,7 @@ public: // Global preferences. sg.addVarSetting(new BoolSetting("app.startupVersionCheck", startupVersionCheck)); sg.addVarSetting(new BoolSetting("app.reportStatistics", reportStatistics)); + sg.addVarSetting(new BoolSetting("app.allowBetaUpgrades", allowBetaUpgrades)); } @@ -145,6 +147,7 @@ public: // Global preferences. bool startupVersionCheck; bool reportStatistics; + bool allowBetaUpgrades; }; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7569d71f9..6ab54e4a3 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: mainwindow.cpp,v 1.17 2010/02/16 02:49:43 robertl Exp $ +// $Id: mainwindow.cpp,v 1.18 2010/04/11 18:11:47 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -45,7 +45,7 @@ const int BabelData::noType = -1; const int BabelData::fileType = 0; const int BabelData::deviceType = 1; //------------------------------------------------------------------------ -static QString findBabelVersion() +QString MainWindow::findBabelVersion() { QProcess babel; babel.start("gpsbabel", QStringList() << "-V"); @@ -56,10 +56,22 @@ static QString findBabelVersion() return QString(); QString str = babel.readAll(); + is_beta = str.contains("-beta"); str.replace(QRegExp("^[\\s]*"), ""); str.replace(QRegExp("[\\s]+$"), ""); return str; } + +//------------------------------------------------------------------------ +// Decides whether available beta upgrades are suggested to user for download. +bool MainWindow::allowBetaUpgrades() +{ + // If this is a beta version (which means the user consciously downloaded + // it and decided to be on the beta track or the user has ticked the + // 'suggest beta upgrade' box, allow betas to be suggested for installation. + return is_beta || bd.allowBetaUpgrades; +} + //------------------------------------------------------------------------ static QStringList getCharSets() { @@ -177,7 +189,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) if (bd.startupVersionCheck) { upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, bd.upgradeCheckTime, bd.installationUuid, - bd.reportStatistics); + bd.reportStatistics, allowBetaUpgrades()); } } @@ -966,8 +978,9 @@ void MainWindow::aboutActionX() void MainWindow::upgradeCheckActionX() { upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, - QDateTime(), bd.installationUuid, - bd.reportStatistics); + QDateTime(QDate(2000, 1, 1), QTime(0, 0)), + bd.installationUuid, + bd.reportStatistics, allowBetaUpgrades()); } //------------------------------------------------------------------------ diff --git a/gui/mainwindow.h b/gui/mainwindow.h index d8c0b0210..017519e41 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: mainwindow.h,v 1.9 2010/02/16 02:49:43 robertl Exp $ +// $Id: mainwindow.h,v 1.10 2010/04/11 18:11:47 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -40,6 +40,7 @@ private: Ui_MainWindow ui; QList formatList; QString babelVersion; + bool is_beta; QPixmap lights[4]; QStringList charSets; AllFiltersData filterData; @@ -50,6 +51,7 @@ private: void loadFormats(); QString filterForFormat(int idx); QString ensureExtensionPresent(const QString &nanme, int idx); + QString findBabelVersion(); bool filterForFormatIncludes(int idx, const QString &s); int formatIndexFromName(bool isFile, const QString &); QListinputFileFormatIndices(); @@ -81,6 +83,7 @@ private: void setWidgetValues(); void getWidgetValues(); UpgradeCheck *upgrade; + bool allowBetaUpgrades(); void osLoadDeviceNameCombos(QComboBox*); protected: diff --git a/gui/upgrade.cpp b/gui/upgrade.cpp index c3b04f200..ca339aac9 100644 --- a/gui/upgrade.cpp +++ b/gui/upgrade.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: upgrade.cpp,v 1.23 2010/02/23 15:38:26 robertl Exp $ +// $Id: upgrade.cpp,v 1.24 2010/04/11 18:11:47 robertl Exp $ /* Copyright (C) 2009, 2010 Robert Lipe, robertlipe@gpsbabel.org @@ -117,7 +117,8 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tV int checkMethod, const QDateTime &lastCheckTime, const QString &installationUuid, - bool reportStatistics) + bool reportStatistics, + bool allowBeta) { currentVersion = currentVersionIn; currentVersion.remove("GPSBabel Version "); @@ -154,8 +155,9 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tV args += "&cpu=" + QString(utsname.machine); } #endif + args += "&os_ver=" + getOsVersion(); - args += "&beta_ok=1"; // Eventually to come from prefs. + args += QString("&beta_ok=%1").arg(allowBeta); args += "&lang=" + QLocale::languageToString(locale.language()); args += "&last_checkin=" + lastCheckTime.toString(Qt::ISODate); diff --git a/gui/upgrade.h b/gui/upgrade.h index 32623317d..880380b3f 100644 --- a/gui/upgrade.h +++ b/gui/upgrade.h @@ -44,7 +44,8 @@ public: int upgradeCheckMethod, const QDateTime &lastCheckTime, const QString &installationUuid, - bool reportStatistics + bool reportStatistics, + bool allowBeta ); QDateTime getUpgradeWarningTime() { return upgradeWarningTime; -- 2.30.2